package com.cicigodd.brick.plug.security;

import com.cicigodd.brick.plug.security.Interceptor.AuthJwtTokenSecurityInterceptor;
import com.cicigodd.brick.plug.security.Interceptor.PermissionSecurityInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * spring mvc的配置
 *
 * @author cicigodd
 * @date 2022/09/23 08:42:00
 */
@Configuration
public class SpringMvcConfiguration implements WebMvcConfigurer {

    @Resource
    private AuthJwtTokenSecurityInterceptor authJwtTokenSecurityInterceptor;

    @Resource
    private PermissionSecurityInterceptor permissionSecurityInterceptor;

    /**
     * 配置项目拦截器
     *
     * @author cicigodd
     * @date 2020/12/18 9:43
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(authJwtTokenSecurityInterceptor);
//        InterceptorRegistration interceptorRegistration1 = registry.addInterceptor(permissionSecurityInterceptor);
        interceptorRegistration.excludePathPatterns("/**/login/**");
        interceptorRegistration.excludePathPatterns("/actuator/health/**");
        interceptorRegistration.excludePathPatterns("/v2/api-docs/**");
        interceptorRegistration.excludePathPatterns("/v2/api-docs-ext/**");
        interceptorRegistration.excludePathPatterns("/swagger-resources");
        interceptorRegistration.excludePathPatterns("/error/**");
        interceptorRegistration.excludePathPatterns("/webjars/**");
        interceptorRegistration.excludePathPatterns("/swagger-ui.html");
        interceptorRegistration.excludePathPatterns("/doc.html");;
        interceptorRegistration.excludePathPatterns("/swagger-resources");
//        interceptorRegistration1.excludePathPatterns("/**/login/**");
//        interceptorRegistration1.excludePathPatterns("/actuator/health/**");
//        interceptorRegistration1.excludePathPatterns("/v2/api-docs/**");
//        interceptorRegistration1.excludePathPatterns("/v2/api-docs-ext/**");
//        interceptorRegistration1.excludePathPatterns("/swagger-resources");
//        interceptorRegistration1.excludePathPatterns("/error/**");
//        interceptorRegistration1.excludePathPatterns("/webjars/**");
//        interceptorRegistration1.excludePathPatterns("/swagger-ui.html");
//        interceptorRegistration1.excludePathPatterns("/doc.html");;
//        interceptorRegistration1.excludePathPatterns("/swagger-resources");
    }

}
